package com.zhangyu.shadow.repair.delegate.luncher;

import com.alibaba.fastjson.TypeReference;
import com.zhangyu.shadow.repair.config.RepairItemType;
import com.zhangyu.shadow.repair.delegate.search.entity.MaintainEntity;

import st.lib.base.ui.recycler.MultipleItemEntity;
import st.lib.base.ui.recycler.ObjConverter;

/**
 * @author zhangyu
 * @date 2018/2/13
 */

public class BusDataConverter {
    /**
     * 转为保养数据
     *
     * @param response
     * @return
     */
    public static MultipleItemEntity convertToMaintain(String response) {
        MaintainEntity maintainEntity = new ObjConverter<MaintainEntity>().
                convert(response, new TypeReference<MaintainEntity>() {
                });
        return MultipleItemEntity
                .builder()
                .setItemType(RepairItemType.ITEM_TYPE_MAINTAIN)
                .setField(RepairItemType.ITEM_MAINTAIN, maintainEntity)
                .build();
    }

    public static MultipleItemEntity convertToRepair(String response) {
        MaintainEntity maintainEntity = new ObjConverter<MaintainEntity>().
                convert(response, new TypeReference<MaintainEntity>() {
                });
        return MultipleItemEntity
                .builder()
                .setItemType(RepairItemType.ITEM_TYPE_REPAIR)
                .setField(RepairItemType.ITEM_MAINTAIN, maintainEntity)
                .build();
    }
}
